package com.kuang.demo.controller;

import com.kuang.demo.bean.BaseRespVo;
import com.kuang.demo.bo.zzy.AdminBo.ListPageLimit;
import com.kuang.demo.bo.zzy.StorageBo.PageLimit3;
import com.kuang.demo.bo.zzy.StorageBo.StorageListRe;
import com.kuang.demo.bo.zzy.TotalItem;
import com.kuang.demo.service.StorageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/admin/storage")
public class StorageController {

    @Autowired
    StorageService storageService;

    @RequestMapping("/list")
    public BaseRespVo zzy1(PageLimit3 pageLimit3){
        TotalItem totalItem = storageService.selectStorageList(pageLimit3);

        return BaseRespVo.ok(totalItem);
    }

    @RequestMapping("/update")
    public BaseRespVo zzy2(@RequestBody StorageListRe storageListRe){
        StorageListRe storageListRe1 = storageService.updateStorage(storageListRe);

        return BaseRespVo.ok(storageListRe1);
    }

    @RequestMapping("/delete")
    private BaseRespVo zzy3(@RequestBody StorageListRe storageListRe){
        storageService.deleteStorage(storageListRe.getId());

        return BaseRespVo.ok();
    }
}
